package cn.tedu.egmvc3.controller;

import cn.tedu.egmvc3.mapper.EmpMapper;
import cn.tedu.egmvc3.pojo.entity.Emp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping(value = "/v1/emp/")
@RestController
public class EmpController {
    @Autowired
    private EmpMapper empMapper;
    @RequestMapping(value = "insert")
    public String insertEmp(Emp emp){
        empMapper.insert(emp);
        return "添加成功";
    }

    @RequestMapping(value = "select")
    public List<Emp> select(){
        return empMapper.selectAll();
    }

    @RequestMapping(value = "update")
    public String update(Emp emp){
        empMapper.update(emp);
        return "修改成功";
    }
    @RequestMapping(value = "delete")
    public String delete(Integer id){
        empMapper.delete(id);
        return "删除成功";
    }
}
